package com.hyperfix.models.simulator.pojos;

import com.baomidou.mybatisplus.annotation.*;
import com.hyperfix.utils.common.RandomUtil;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.io.Serializable;
import java.time.LocalDateTime;

/**
 * @author JiangChunYu
 * 2024/4/19
 */
@Data
@TableName("flow_table")
@EqualsAndHashCode
public class FlowTable implements Serializable {
    private static final long serialVersionUID = 1L;

    /**
     * 流量表编号
     */
    @TableId(value = "id", type = IdType.AUTO)
    private Integer id;
    /**
     * 管线编号
     */
    private Integer pipelineId;
    /**
     * 流量表数值
     */
    private Long value;
    /**
     * 昨天流量表最大值
     */
    private Long yesterdayValue;
    /**
     * 重置时间
     */
    private LocalDateTime calibrationTime;
    /**
     * 更新时间
     */
    @TableField(fill = FieldFill.UPDATE)
    private LocalDateTime updateTime;

    private static final int MAX_VALUE = 160; // 增量最大值

    private static final int Min_VALUE = 120; // 增量最小值

    public void increase() {
        int increment = RandomUtil.nextRangeInt(MAX_VALUE, Min_VALUE);
        this.value += increment;
    }
}
